package chenjiuxu.seniorui.study;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import chenjiuxu.seniorui.R;

/**
 * Created by 15705 on 2017/12/26.
 */

public class MatrixView extends View {
    private final Paint paint;
    private final Bitmap bitmap;
    private final int w;
    private final int h;

    public MatrixView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        paint = new Paint();
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.imga);
        w = bitmap.getWidth();
        h = bitmap.getHeight();

    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Matrix matrix = new Matrix();
//      matrix.setTranslate(200, 200);//平移
//      matrix.postScale(0.5f, 0.5f);//缩放
//      matrix.setRotate(45);//旋转 角度
//      matrix.setSinCos(1, 0);//旋转 正弦和余弦值
        matrix.setSkew(0, 0.5f, 0, 0);//旋转 正弦和余弦值
        canvas.drawBitmap(bitmap, matrix, paint);
    }
}
